package com.hzdl.service;

import com.hzdl.bean.Agreement;
import com.hzdl.bean.AgreementDetail;
import com.hzdl.dao.AgreementDao;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: bxc
 * @date: 2018/9/5 0005
 * @description: 合同service类
 */
@Service
public class AgreementService {

    @Autowired
    private AgreementDao agreementDao;

    //根据项目ID获取该项目下的所有合同信息
    public List<AgreementDetail> getAllAgreement(long prid) {
        return agreementDao.getAllAgreement(prid);
    }

    //根据合同ID更新对应合同信息(终止合同)
    public void updateAgreement(long aid, String nowTime, String state) {
        agreementDao.updateAgreement(aid, nowTime, state);
    }

    //添加新合同
    public void addAgreement(AgreementDetail agreementDetail) {
        agreementDao.addAgreement(agreementDetail);
    }

    //获取房间下的所有历史合同
    public List<Agreement> getAllHistoryAgreen(int rid) {
        return agreementDao.getAllHistoryAgreen(rid);
    }


    //更新合同收益
    public void updateAgreen(long value, long aid) {
        agreementDao.updateAgreen(value, aid);
    }

//列出异常合同
    public List<AgreementDetail> getArrearsAgm() {
        return agreementDao.getArrearsAgm();
    }

   //在请求时更新异常合同
 /*   public void updateIsNormal() {
        List<AgreementDetail> details = agreementDao.listAll();
        Map<String, Object> params = null;
        for (AgreementDetail detail : details) {
            params = new HashMap<String, Object>();
            params.put("start", detail.getStart_time());
            params.put("period", detail.getPay_period());
            params.put("free", detail.getFree_period());
            params.put("income", detail.getIncome());
            params.put("pp", detail.getPeriod_pay());
            params.put("idi", detail.getId());
            agreementDao.updateIsNormal(params);
        }
    }*/
}


